<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Class: ActionController::Routing::Optimisation::PositionalArgumentsWithAdditionalParams</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../../../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Class</strong></td>
          <td class="class-name-in-header">ActionController::Routing::Optimisation::PositionalArgumentsWithAdditionalParams</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../../../files/vendor/rails/actionpack/lib/action_controller/routing_optimisation_rb.html">
                vendor/rails/actionpack/lib/action_controller/routing_optimisation.rb
                </a>
        <br />
            </td>
        </tr>

        <tr class="top-aligned-row">
            <td><strong>Parent:</strong></td>
            <td>
                <a href="PositionalArguments.html">
                PositionalArguments
               </a>
            </td>
        </tr>
        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">

    <div id="description">
      <p>
This case is mostly the same as the positional arguments case above, but it
supports additional query parameters as the last argument
</p>

    </div>


   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000343">applicable?</a>&nbsp;&nbsp;
      <a href="#M000342">generation_code</a>&nbsp;&nbsp;
      <a href="#M000341">guard_condition</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">





      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000343" class="method-detail">
        <a name="M000343"></a>

        <div class="method-heading">
          <a href="#M000343" class="method-signature">
          <span class="method-name">applicable?</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
To avoid generating <a
href="http://localhost/?host=foo.example.com">localhost/?host=foo.example.com</a>
we can&#8216;t use this optimisation on routes without any segments
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000343-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000343-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/actionpack/lib/action_controller/routing_optimisation.rb, line 111</span>
111:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">applicable?</span>
112:           <span class="ruby-keyword kw">super</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">route</span>.<span class="ruby-identifier">segment_keys</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span> 
113:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000342" class="method-detail">
        <a name="M000342"></a>

        <div class="method-heading">
          <a href="#M000342" class="method-signature">
          <span class="method-name">generation_code</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
This case uses almost the same code as positional arguments, but add an
args.last.to_query on the end
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000342-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000342-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/actionpack/lib/action_controller/routing_optimisation.rb, line 105</span>
105:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">generation_code</span>
106:           <span class="ruby-keyword kw">super</span>.<span class="ruby-identifier">insert</span>(<span class="ruby-value">-2</span>, <span class="ruby-value str">'?#{args.last.to_query}'</span>)
107:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000341" class="method-detail">
        <a name="M000341"></a>

        <div class="method-heading">
          <a href="#M000341" class="method-signature">
          <span class="method-name">guard_condition</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000341-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000341-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/actionpack/lib/action_controller/routing_optimisation.rb, line 99</span>
 99:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">guard_condition</span>
100:           <span class="ruby-node">&quot;defined?(request) &amp;&amp; request &amp;&amp; args.size == #{route.segment_keys.size + 1} &amp;&amp; !args.last.has_key?(:anchor) &amp;&amp; !args.last.has_key?(:port) &amp;&amp; !args.last.has_key?(:host)&quot;</span>
101:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>